package com.ymttest.database.model.mongo.query;


import java.util.Date;

import org.springframework.data.annotation.Id;
import org.springframework.data.mongodb.core.mapping.Field;

import com.ymttest.database.model.annotation.Column;
import com.ymttest.database.model.annotation.Table;

/**
 * 买家索引
 * Created by zhangyifan on 2016/12/8.
 */
public class UserIndex {

    /**
     * 订单ID
     */
    @Table("Ymt_Orders")
    @Column("iOrderId")
    @Id
    private Long id;
    /**
     * 买家ID
     */
    @Table("Ymt_Orders")
    @Column("iUserId")
    @Field("user")
    private Long userId;

    /**
     * 主单ID
     */
    @Table("Ymt_Orders")
    @Column("iMainOrderId")
    @Field("main")
    private Long mainOrderId;

    /**
     * 订单状态
     */
    @Table("Ymt_Orders")
    @Column("iTradingStatus")
    @Field("st")
    private Integer tradingStatus;

    /**
     * 下单时间
     */
    @Table("Ymt_Orders")
    @Column("dAddTime")
    @Field("addTm")
    private Date addTime;

    /**
     * 是否删除
     */
    @Table("Ymt_Orders")
    @Column("bDeleted")
    @Field("del")
    private boolean deleted;

    /**
     * 能够评价且未评价 (Order表 CAN_EVALUATE && !EVALUATED)
     */
    @Table("Ymt_Orders")
    @Field("eva")
    private boolean needsEvaluate;

    /**
     * 收货时间
     */
    @Table("Ymt_Orders")
    @Column("dConfirmedTime")
    @Field("recvTm")
    private Date receiveTime;


    /**
     * 插入时间
     */
    @Field("aT")
    private Date timeMongoAdd;

    /**
     * 更新时间
     */
    @Field("uT")
    private Date timeMongoUpdate;

    public Long getId() {
        return id;
    }

    public void setId(Long id) {
        this.id = id;
    }

    public Long getUserId() {
        return userId;
    }

    public void setUserId(Long userId) {
        this.userId = userId;
    }

    public Long getMainOrderId() {
        return mainOrderId;
    }

    public void setMainOrderId(Long mainOrderId) {
        this.mainOrderId = mainOrderId;
    }

    public Integer getTradingStatus() {
        return tradingStatus;
    }

    public void setTradingStatus(Integer tradingStatus) {
        this.tradingStatus = tradingStatus;
    }

    public Date getAddTime() {
        return addTime;
    }

    public void setAddTime(Date addTime) {
        this.addTime = addTime;
    }

    public boolean getDeleted() {
        return deleted;
    }

    public void setDeleted(boolean deleted) {
        this.deleted = deleted;
    }

    public boolean getNeedsEvaluate() {
        return needsEvaluate;
    }

    public void setNeedsEvaluate(boolean needsEvaluate) {
        this.needsEvaluate = needsEvaluate;
    }

    public Date getReceiveTime() {
        return receiveTime;
    }

    public void setReceiveTime(Date receiveTime) {
        this.receiveTime = receiveTime;
    }

    public Date getTimeMongoAdd() {
        return timeMongoAdd;
    }

    public void setTimeMongoAdd(Date timeMongoAdd) {
        this.timeMongoAdd = timeMongoAdd;
    }

    public Date getTimeMongoUpdate() {
        return timeMongoUpdate;
    }

    public void setTimeMongoUpdate(Date timeMongoUpdate) {
        this.timeMongoUpdate = timeMongoUpdate;
    }

    @Override
    public boolean equals(Object o) {
        if (this == o) return true;
        if (!(o instanceof UserIndex)) return false;

        UserIndex userIndex = (UserIndex) o;

        if (getDeleted() != userIndex.getDeleted()) return false;
        if (getNeedsEvaluate() != userIndex.getNeedsEvaluate()) return false;
        if (getId() != null ? !getId().equals(userIndex.getId()) : userIndex.getId() != null) return false;
        if (getUserId() != null ? !getUserId().equals(userIndex.getUserId()) : userIndex.getUserId() != null)
            return false;
        if (getMainOrderId() != null ? !getMainOrderId().equals(userIndex.getMainOrderId()) : userIndex.getMainOrderId() != null)
            return false;
        if (getTradingStatus() != null ? !getTradingStatus().equals(userIndex.getTradingStatus()) : userIndex.getTradingStatus() != null)
            return false;
        if (getAddTime() != null ? !getAddTime().equals(userIndex.getAddTime()) : userIndex.getAddTime() != null)
            return false;
        return getReceiveTime() != null ? getReceiveTime().equals(userIndex.getReceiveTime()) : userIndex.getReceiveTime() == null;

    }

    @Override
    public int hashCode() {
        int result = getId() != null ? getId().hashCode() : 0;
        result = 31 * result + (getUserId() != null ? getUserId().hashCode() : 0);
        result = 31 * result + (getMainOrderId() != null ? getMainOrderId().hashCode() : 0);
        result = 31 * result + (getTradingStatus() != null ? getTradingStatus().hashCode() : 0);
        result = 31 * result + (getAddTime() != null ? getAddTime().hashCode() : 0);
        result = 31 * result + (getDeleted() ? 1 : 0);
        result = 31 * result + (getNeedsEvaluate() ? 1 : 0);
        result = 31 * result + (getReceiveTime() != null ? getReceiveTime().hashCode() : 0);
        return result;
    }
}
